package com.honghu.villagepost.activity.fragment;

import android.os.Bundle;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;

import com.blankj.utilcode.util.ObjectUtils;
import com.blankj.utilcode.util.SizeUtils;
import com.honghu.villagepost.R;
import com.honghu.villagepost.adapter.DemandAdapter;
import com.honghu.villagepost.base.BaseFragment;
import com.honghu.villagepost.widget.SpaceItemDecoration;
import com.scwang.smart.refresh.layout.SmartRefreshLayout;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @author mqwang
 */
public class DemandListFragment extends BaseFragment {
    @BindView(R.id.et_search)
    EditText mEtSearch;
    @BindView(R.id.rv_list)
    RecyclerView mRecLv;
    @BindView(R.id.refreshLayout)
    SmartRefreshLayout mRefreshLayout;

    private static final String CATE_ID = "cate_id";
    private String mCateId;
    private DemandAdapter mDemandAdapter;

    public static DemandListFragment newInstance(String type) {
        DemandListFragment fragment = new DemandListFragment();
        Bundle bundle = new Bundle();
        bundle.putString(CATE_ID, type);
        fragment.setArguments(bundle);
        return fragment;

    }

    @Override
    protected View initViews(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_demand_list, container, false);
        return view;
    }

    @Override
    protected void initData() {
        mRefreshLayout.setEnableRefresh(true);
        Bundle arguments = getArguments();
        if (ObjectUtils.isNotEmpty(arguments)){
            mCateId = arguments.getString(CATE_ID);
        }

        mDemandAdapter = new DemandAdapter();
        mRecLv.setLayoutManager(new LinearLayoutManager(getActivity()));
        mRecLv.addItemDecoration(new SpaceItemDecoration(0, SizeUtils.dp2px(5)));
        mRecLv.setAdapter(mDemandAdapter);

        mDemandAdapter.addData("");
        mDemandAdapter.addData("");
        mDemandAdapter.addData("");

    }

    @OnClick(R.id.tv_sx)
    public void onViewClicked() {
    }
}
